{include file="general/header.tpl"}
{include file="preview/preview_path.tpl"}
<div id="main">
	{validate form="preview" id="v_link_url" append="error" message="Link is not valid."}
	{if $preview_button}
		<div class="failed">
			{assign var="session_name" value=#SessionName#}
			{if !$smarty.cookies.$session_name}
				Either your session has expired or you have to accept cookies from this site before using it.<br />
			{/if}
			{foreach $error as $message}
				{$message}<br />
			{foreachelse}
				{if $smarty.cookies.$session_name && $error@total == 0 && !$good_link}
					{assign var="custom_error" value="true"}
					Either this link was not found in our database or it is disabled.<br />
				{/if}
				{if !$custom_error}
					An unknown session error occured. Do not refresh the page or submit the form, just click again on the link that brought you to this page to create a new session.<br />
				{/if}
			{/foreach}
		</div>
	{/if}
	<h1>Preview link</h1>
	<form action="" method="post">
		<div class="form-field">
			<label>Provide tiny link:</label>
			<input type="text" name="link" value="{$link|escape}" />
		</div>
		<div class="form-field">
			<label>&nbsp;</label>
			{assign var="preview_name" value=#PreviewCookieName#}
			<input type="checkbox" name="preview" value="1" {if $smarty.cookies.$preview_name}checked="checked" {/if}onclick="if (this.checked) Set_Cookie('{#PreviewCookieName#}', '1', 365); else Delete_Cookie('{#PreviewCookieName#}');" /> Always preview links from this site
			<br /><br />
		</div>
		<div class="form-field">
			<label>&nbsp;</label>
			<input type="submit" name="preview_button" value="Preview" />
		</div>
	</form>
</div>
{include file="general/left.tpl"}
{include file="general/footer.tpl"}